<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>${name_china}管理列表</title>
<%@include file="/common/head.jsp" %>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
        </div>
        <div id="toolbar" style="float: right"></div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>        
    </div>
    <div class="page-title-border"></div>
</div>

<div class="search-field">
	<!-- <span class="field-cont">
        <span class="field-cont-title">用户名</span>
        <input type="text" class="summer-input" id="userNickName" />
    </span> -->
    <span class="field-cont">
        <span class="field-cont-title">日期</span>
        <input type="text" class="summer-input" id="createTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/>
    </span>
    <span class="field-cont">
        <span class="field-cont-title">-</span>
        <input type="text" class="summer-input" id="updateTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/>    
    </span>
    <span class="field-btn-wrapper">
        <a id="search" class="btn btn-primary btn-icon wave distance-right"><i class="icon icon-search"></i></a>
        <a id="reset" class="btn btn-icon wave wave-dark"><i class="icon icon-refresh"></i></a>
    </span>
</div>

<div id="t-wrap">
    <table class="summer-datagrid" id="dataList">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="30%">
	    <thead>
		    <tr>
		        <th>类型</th>
		        <th>昵称/ID</th>
		        <th>积分数</th>
		        <th>积分总数</th>
		        <th>时间</th>
		        <th>操作</th>
		    </tr>
	    </thead>
    </table>
</div>

<script>
	//请求url
	var CONST_URL = {
		LIST: basePath + '${common_url}list',
	   	INIT_ADD: basePath + "${common_url}initAdd",
	   	INIT_EDIT: basePath + "${common_url}initEdit",
	   	INIT_VIEW: basePath + "${common_url}initView",
	   	DEL: basePath + "${common_url}del",
	   	VIEW_LEVEL: basePath + "${common_url}viewLevel",
	   	SETBLACK: basePath + "${common_url}setblack",
	   	PRE_INCOME: basePath + "${common_url}preIncome",
	   	INIT_POINTS: basePath + "${common_url}initPoints",
	   	GET_POINTS: basePath + "${common_url}getPoints",
		INIT_MAIN : basePath + "${common_url}init"
	};
	
    var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	
    	
        // 新建toobar
		$.funcbar({
			id: 'toolbar',
			type: 'toolbar',
			data: permission,
			permit: ['${name_english}:initAdd']
		});
        
        // 查询按钮
        $('#search').on('click', reloadTable);
        
        //重置按钮
        $('#reset').on('click', function () {
        	//重置文本框的值
        	$('#createTime').val('');
        	$('#updateTime').val('');
        	$('#userNickName').val('');
        	reloadTable();
        });
        
        
       createTable();
		$('#goBack').on('click', backMain);    
    });
  //返回主页面
	function backMain() {
		var id = ${id};
		window.location.href = CONST_URL.INIT_EDIT+"?id="+id;
		}
    // 重新加载表格
	function reloadTable() {
		$('#dataList').datagrid('reload',{
            ajax: {
            	param: {
            		"createTime": trimSpace($('#createTime').val()),
            		"updateTime": trimSpace($('#updateTime').val())/* ,
            		"userNickName": trimSpace($('#userNickName').val()) */
            	}
            }
        });
	}
    
    //创建表格
    function createTable() {
    	var id = ${id};
    	$('#dataList').datagrid({
    		ajax: {
    			url: CONST_URL.GET_POINTS+"?id="+id,
    			param: {
    				"createTime": trimSpace($('#createTime').val()),
    				"updateTime": trimSpace($('#updateTime').val()),
    				"id": trimSpace($('#id').val())
            	}
    		},
    		columns: [
    		     {
    		    	 field: 'id',
    		    	 hidden: true
    		     },
    		     {
    		    	 field: 'type'
    		     },
    		     {
    		    	 field:'userNickName'
    		     },
    		     {
    		    	 field: 'userPhone'
    		     },
    		     {
    		    	 field: 'points'
    		     },
    		     {
    		    	 field: 'sumPoints'
    		     },
    		     {
    		    	 field: 'createTime'
    		     },
    		     {
    		    	 render: function (rowData) {
    		    		 return $.funcbar({
    		    			 data: permission,    //请求的数据
    		    			 type: 'text',     //类型
    		    			 display: 4,    //显示数量
    		    			 permit: ['${name_english}:del'] //需要的权限按钮
    		    		 });
    		    	 }
    		    }   
    	    ]
    	});
    }   
</script>
</body>
</html>